package com.southpark.demo.view.skins
{
	import flash.filters.BitmapFilterQuality;
	import flash.filters.GlowFilter;
	
	import mx.core.EdgeMetrics;
	import mx.skins.halo.PanelSkin;	
	
	public class GlowSkin extends PanelSkin
	{		
		
		override public function get borderMetrics():EdgeMetrics
		{
			return new EdgeMetrics(14,14,14,14);
		}	
		
		override protected function updateDisplayList(unscaledWidth:Number,unscaledHeight:Number):void
		{
			super.updateDisplayList(unscaledWidth,unscaledHeight);
			render(0x868688,unscaledWidth,unscaledHeight);
		}
		
		protected function render(glowColor:uint,unscaledWidth:Number,unscaledHeight:Number):void
		{
			var backgroundColor:uint = getStyle("backgroundColor");
			if (!backgroundColor) backgroundColor = 0xFFFFFF;
			
			var backgroundAlpha:Number = getStyle("backgroundAlpha");
			if (!backgroundAlpha) backgroundAlpha = 1;
						
			graphics.clear();
			graphics.beginFill(backgroundColor,backgroundAlpha);
			graphics.drawRect(0,0,unscaledWidth,unscaledHeight);
			graphics.endFill();
			
			var glow:GlowFilter = new GlowFilter();
			glow.color = glowColor;
			glow.alpha = 0.5;
			glow.blurX = 6;
			glow.blurY = 6;
			glow.quality = BitmapFilterQuality.MEDIUM;
			
			filters = [glow];
		}
	}
}